package marchenko.springdao.repository.book_class;

import java.sql.ResultSet;
import java.sql.SQLException;

import marchenko.springdao.domain.Author;
import marchenko.springdao.domain.BookClass;
import marchenko.springdao.domain.Genre;

import org.springframework.jdbc.core.RowMapper;

class BookClassMapper implements RowMapper<BookClass> {
	
	public BookClass mapRow(ResultSet resultSet, int i) throws SQLException {
		BookClass BookClass = new BookClass();
		BookClass.setClassId(resultSet.getInt("id"));
		BookClass.setClassName(resultSet.getString("name"));
		Author author = new Author();
		author.setAuthorId(resultSet.getInt("author_id"));
		author.setAuthorName(resultSet.getString("author_name"));
		BookClass.setAuthor(author);
		Genre genre = new Genre();
		genre.setGenreId(resultSet.getInt("genre_id"));
		genre.setGenreName(resultSet.getString("genre_name"));
		BookClass.setGenre(genre);
		BookClass.setDescription(resultSet.getString("description"));
		return BookClass;
	}
}